package com.linewell.system.dao.impl;

import java.util.List;

import org.hibernate.Query;
import org.springframework.stereotype.Repository;

import com.linewell.commom.dao.impl.BaseDaoImpl;
import com.linewell.system.dao.ISysMenusDao;
import com.linewell.system.model.SysMenuActions;
import com.linewell.system.model.SysMenus;
@Repository
public class SysMenusDaoImpl extends BaseDaoImpl<SysMenus> implements ISysMenusDao{

	@SuppressWarnings("unchecked")
	@Override
	public List<SysMenuActions> getAction(String id) {
		String hql = " from SysMenuActions where menuId ="+id;
		Query query = super.sessionFactory.getCurrentSession().createQuery(hql);
		return  query.list();
	}

	@Override
	public boolean deleteOne(Integer id) {
		String hql = "delete SysMenuActions s where s.menuId in ("+id+") ";
		Query query = super.sessionFactory.getCurrentSession().createQuery(hql);
		return (query.executeUpdate() > 0);
	}

	@Override
	public boolean saveUrl(String url, Integer id) {
		String sql = "insert into sys_menu_actions(ACTION_URL,MENU_ID) values('"+url+"',"+id+") ";
		Query query = super.sessionFactory.getCurrentSession().createSQLQuery(sql);
		return (query.executeUpdate() > 0);
	}

	
	
	

	
	
          
	   
	
	
}
